<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分布式锁：现代分布式系统的守护者</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .number-circle {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            color: white;
            font-weight: bold;
            flex-shrink: 0;
        }
        
        .section-title {
            position: relative;
            display: inline-block;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .mermaid {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-size: 2.5rem;
        }
        
        @keyframes float {
            0% { transform: translateY(0px); }
            50% { transform: translateY(-10px); }
            100% { transform: translateY(0px); }
        }
        
        .float-animation {
            animation: float 3s ease-in-out infinite;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center">
            <div class="float-animation inline-block mb-6">
                <i class="fas fa-lock text-6xl opacity-90"></i>
            </div>
            <h1 class="text-5xl md:text-6xl font-bold mb-6" style="font-family: 'Noto Serif SC', serif;">
                分布式锁
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">
                现代分布式系统的守护者
            </p>
            <div class="max-w-3xl mx-auto">
                <p class="text-lg leading-relaxed opacity-80">
                    在分布式系统的复杂世界中，分布式锁如同一位智慧的协调者，确保着数据的一致性、资源的有序访问，以及系统的稳定运行。它是解决分布式环境下并发问题的关键机制。
                </p>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="bg-white rounded-2xl shadow-xl p-8 md:p-12">
                <h2 class="text-3xl font-bold mb-6 section-title">核心概念</h2>
                <p class="text-lg leading-relaxed text-gray-700 mt-8">
                    在分布式系统中，分布式锁是一种用于协调和控制对共享资源的访问的机制，特别是在跨多个节点和服务时。分布式锁是解决分布式环境下的并发问题和资源管理的核心工具。
                </p>
            </div>
        </div>
    </section>

    <!-- Visual Diagram Section -->
    <section class="py-16 px-6 bg-gray-50">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold mb-12 text-center">
                <span class="text-gradient">分布式锁的核心价值体系</span>
            </h2>
            <div class="mermaid">
                graph TD
                    A[分布式锁] --> B[资源管理]
                    A --> C[并发控制]
                    A --> D[数据一致性]
                    A --> E[系统协调]
                    
                    B --> B1[保证资源唯一性]
                    B --> B2[防止资源饥饿]
                    
                    C --> C1[避免重复操作]
                    C --> C2[解决竞争条件]
                    
                    D --> D1[确保数据一致性]
                    D --> D2[支持分布式事务]
                    
                    E --> E1[协调跨节点操作]
                    E --> E2[实现任务调度]
                    E --> E3[实现全局唯一性]
                    E --> E4[防止并发异常]
                    
                    style A fill:#667eea,stroke:#fff,stroke-width:3px,color:#fff
                    style B fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style C fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style D fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
                    style E fill:#9f7aea,stroke:#fff,stroke-width:2px,color:#fff
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold mb-12 text-center">
                <span class="text-gradient">十大核心作用</span>
            </h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Card 1 -->
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="number-circle mr-4">1</div>
                        <h3 class="text-2xl font-bold flex-1">保证资源的唯一性</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <span class="inline-block bg-red-100 text-red-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-exclamation-triangle mr-1"></i>问题
                            </span>
                            <p class="text-gray-700">在分布式系统中，多个节点可能会同时尝试访问或修改同一个资源（如文件、数据库记录、缓存等）。如果没有有效的控制机制，可能会导致数据不一致或冲突。</p>
                        </div>
                        <div>
                            <span class="inline-block bg-green-100 text-green-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-check-circle mr-1"></i>解决方案
                            </span>
                            <p class="text-gray-700">通过分布式锁，可以确保在同一时刻只有一个节点能够访问或修改共享资源，从而保证资源的唯一性和一致性。</p>
                        </div>
                    </div>
                </div>

                <!-- Card 2 -->
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="number-circle mr-4">2</div>
                        <h3 class="text-2xl font-bold flex-1">避免重复操作</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <span class="inline-block bg-red-100 text-red-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-exclamation-triangle mr-1"></i>问题
                            </span>
                            <p class="text-gray-700">在分布式系统中，重复操作可能会导致数据重复或业务逻辑错误。例如，在分布式任务调度中，可能会有多个节点试图执行同一任务。</p>
                        </div>
                        <div>
                            <span class="inline-block bg-green-100 text-green-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-check-circle mr-1"></i>解决方案
                            </span>
                            <p class="text-gray-700">通过分布式锁，可以确保同一任务或操作只会被一个节点执行，从而避免重复执行和产生重复数据。</p>
                        </div>
                    </div>
                </div>

                <!-- Card 3 -->
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="number-circle mr-4">3</div>
                        <h3 class="text-2xl font-bold flex-1">协调跨节点的操作</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <span class="inline-block bg-red-100 text-red-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-exclamation-triangle mr-1"></i>问题
                            </span>
                            <p class="text-gray-700">在分布式系统中，多个节点可能需要进行协调操作，例如分布式数据库中的事务管理、分布式缓存的同步等。</p>
                        </div>
                        <div>
                            <span class="inline-block bg-green-100 text-green-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-check-circle mr-1"></i>解决方案
                            </span>
                            <p class="text-gray-700">分布式锁可以帮助协调不同节点之间的操作，确保它们按照预期的顺序进行，防止并发冲突。</p>
                        </div>
                    </div>
                </div>

                <!-- Card 4 -->
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="number-circle mr-4">4</div>
                        <h3 class="text-2xl font-bold flex-1">实现全局唯一性</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <span class="inline-block bg-red-100 text-red-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-exclamation-triangle mr-1"></i>问题
                            </span>
                            <p class="text-gray-700">某些场景下，需要保证某些资源在整个分布式系统中的唯一性，例如生成全局唯一的ID。</p>
                        </div>
                        <div>
                            <span class="inline-block bg-green-100 text-green-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-check-circle mr-1"></i>解决方案
                            </span>
                            <p class="text-gray-700">通过分布式锁，可以确保全局唯一的资源（如ID生成器）只在一个节点上生成，从而避免冲突和重复。</p>
                        </div>
                    </div>
                </div>

                <!-- Card 5 -->
                <div class="bg-white rounded-xl shadow-lg p-8 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="number-circle mr-4">5</div>
                        <h3 class="text-2xl font-bold flex-1">确保数据一致性</h3>
                    </div>
                    <div class="ml-14">
                        <div class="mb-4">
                            <span class="inline-block bg-red-100 text-red-600 px-3 py-1 rounded-full text-sm font-semibold mb-2">
                                <i class="fas fa-exclamation-triangle mr-1"></i>